package com.itheima.method;

public class MethodDemo1 {
    public static void main(String[] args) {

        int sum = getSum(10,20);
        System.out.println(sum);

        System.out.println("--------------------------------");

        String code = getCode(4);
        System.out.println(code);
        String code1 = getCode(6);
        System.out.println(code1);
    }

    //定义一方法，求两个整数的和并返回
    public static int getSum(int a,int b){
        int sum = a + b;
        return sum;
    }

    //定义一方法，能生成指定位数的验证码并返回
    public static String getCode(int len){
        String code = "";
        for (int i = 0; i < len; i++) {
            int num = (int)(Math.random()*10);
            code += num;
        }
        return code;
    }

}
